/*
 * @Author: 叶敏轩 mc20000406@163.com
 * @Date: 2024-01-23 11:17:17
 * @LastEditors: 叶敏轩 mc20000406@163.com
 * @LastEditTime: 2024-01-26 10:49:22
 * @FilePath: /waterfull/vite.config.ts
 * @Description:
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import packageJSON from './package.json'
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [vue(),cssInjectedByJsPlugin()],
  server: {
    port: 8080,
  },
  
  build: {
    minify: true,
    outDir: "dist",
    lib: {
      entry: [__dirname + "/src/index.ts"],
      name: packageJSON.name,
      formats: ["es"],
      fileName: (format, entryName) => {
        return `${entryName}.${format}.js`;
      },
    },
    rollupOptions: {
      external: ["vue"],
    },
  },
  resolve: {
    // 配置路径别名
    alias: {
      "@": path.resolve(__dirname, "./src"),
      "@api": path.resolve(__dirname, "./src/api"),
      "@assets": path.resolve(__dirname, "./src/assets"),
      "@common": path.resolve(__dirname, "./src/common"),
      "@components": path.resolve(__dirname, "./src/components"),
      "@store": path.resolve(__dirname, "./src/store"),
      "@views": path.resolve(__dirname, "./src/views"),
    },
  },
});
